<?php

namespace Error;

class ErrorModel {

    /**
     * 抛出错误
     * 
     * @param int $code
     */
    public static function throwException($code, $message = null) {
        if (!$message) {
            $text = \Text\TextModel::getText($code);
            if (empty($text)) {
                throw new \Exception('错误码' . $code . '的相应提示信息没有设置');
            }

            $message = $text;
        }

        throw new \Exception($message, $code);
    }

}
